package com.wang.hashtest;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

//使用迭代器（Iterator）keySet 的方式进行遍历
public class HashMapTest2 {
    public static void main(String[] args) {
        Map<Integer, String> map = new HashMap();
        map.put(1,"java");
        map.put(2,"c++");
        map.put(3,"golang");
        map.put(4,"python");
        map.put(5,"php");

        Iterator<Integer> iterator = map.keySet().iterator();
        while (iterator.hasNext()) {
            Integer key = iterator.next();
            System.out.print(key);
            System.out.print(map.get(key));
        }
    }
}
